home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / varia / silo.lha / silo / Counter.h < prev    next >
C/C++ Source or Header  |  1993-08-08  |  726b  |  33 lines

  1. /* $Author: sam $ $Date: 90/07/11 13:31:58 $ $Revision: 1.1 $ */
  2.  
  3. #ifndef Counter_H
  4. #define Counter_H
  5.  
  6. class Counter {
  7. private:
  8.    double current;
  9.    double cycle;
  10. public:
  11.    Counter(double init = 0, double tck = 1);
  12.  
  13.    void set(const double t)        { current = t; }
  14.    void tick(const double t)        { cycle = t; }
  15.  
  16.    double operator () () const        { return current; }
  17.    void operator += (const double inc)    { current += inc; }
  18.    void operator -= (const double dec)    { current -= dec; }
  19.    void operator -- ()            { current -= cycle; }
  20.    void operator ++ ()            { current += cycle; }
  21.  
  22.    double tick() const            { return cycle; }
  23. };
  24.  
  25. inline
  26. Counter::Counter(double init, double tck)
  27. {
  28.    current = init, cycle = tck;
  29. }
  30.  
  31. #endif Counter_H
  32.  
  33.